<div id="content" style="padding-top:5px;">
<?php require_once 'inc/zhaofang_tiaojian.php'; ?>
<?php
    if(true){
    //page_1
      if ($_GET['page']) {
        $page = $_GET['page'];
        if(is_numeric($page)){
        }else{
          $page = 1;
        }
      } else {
        $page = 1;
      }
      $per_page = 20;//每页显示20条
      if($page<=1){$page=1;}//最大值还没有设置,在后面的db结果设置
      $start_from = ($page-1)*$per_page;
    }
    if($_GET['cond'] == 'qiuzu'){
      $post_url = "geren.php?main=qiuzu_post";
    }else{
      $post_url = "geren.php?main=qiugou_post";
    }

?>
<div id="filter">
<style>
  .tabs a{
    text-decoration: none;
  }
  .tabs a:hover{
    padding-top:1px;
  }
</style>
<div class="tabs"><a href="<?php echo $post_url;?>" class="pubbtn">免费发布找房信息»</a><a <?php if(!($_GET['cond'])){echo ' class="select" ';}?> href="<?echo deleteRepeatVar($current_url,'cond');?>"><span>全部</span></a>
<a href="<?echo deleteRepeatVar($current_url,'cond');?>&cond=qiuzu" <?php if($_GET['cond']=='qiuzu'){echo ' class="select" ';}?>><span>求租</span></a>
<a href="<?echo deleteRepeatVar($current_url,'cond');?>&cond=qiugou" <?php if($_GET['cond']=='qiugou'){echo ' class="select" ';}?>><span>求购</span></a>
</div>
</div>



<div id="main">
<div id="infolist">
<div id="top_google_ad" style="display: none;"></div>
<table class="tblist" cellpadding="0" cellspacing="0">
  <colgroup>
    <col>
    <col class="cotext3" style="width: 200px">
    <col class="cotext3">
    <col class="cotext3">
  </colgroup>
  <tbody>
  <?php
      require_once ("./includes/configure.php");
      require_once ("./includes/database.php");
      $db = Database :: Connect();

      $where_sql = ' where 1=1 ';
      $var_quyu = $_GET['quyu'];
      if($var_quyu){
        $where_sql .= ' and quyu='.$db->Encode($var_quyu);
      }
	  
	  
		if($_GET['quyu2']){
			$where_sql .= " and quyu2=".$_GET['quyu2']." ";
		}
	  
      if($_GET['cond'] == 'qiuzu'){
         $where_sql .= ' and qiuzu_qiugou=1 ';
         $var_zujin = $_GET['zujin'];
        if($var_zujin){
          $where_sql .= " and zujin_goujia='".$db->Encode($var_zujin)."'";
        }
      }else if($_GET['cond'] == 'qiugou'){
        $where_sql .= ' and qiuzu_qiugou=2 ';
        $var_shoujia = $_GET['shoujia'];
        if($var_shoujia){
          $where_sql .= " and zujin_goujia='".$db->Encode($var_shoujia)."'";
        }
        $var_mianji = $_GET['mianji'];
        if($var_mianji){
          $where_sql .= " and mianji='".$db->Encode($var_mianji)."'";
        }
        $var_leixing = $_GET['leixing'];
        if($var_leixing){
          $where_sql .= " and leixing='".$db->Encode($var_leixing)."'";
        }
      }

      /*发布的时候，没有设置线路
        $var_xianlu = $_GET['xianlu'];
        if($var_xianlu){
          $where_sql .= ' and xianlu='.$db->Encode($var_xianlu);
        }
      */

      $var_huxing = $_GET['huxing'];
      if($var_huxing){
        $where_sql .= " and fangxing='".$db->Encode($var_huxing)."'";
      }

      $sql = "select * from qiuzu_qiugou $where_sql order by fabushijian desc limit $start_from,$per_page";
      if(true){
      //page_2
        $count_sql = "select count(*) from qiuzu_qiugou $where_sql order by fabushijian desc";
        $count_result = $db->GetResultSet($count_sql);
        while ($count_row = mysql_fetch_array($count_result)) {
          $total_item = $count_row[0];
        }
        $max_page = ceil($total_item/$per_page);
      }
      //echo $sql;
      $rows = $db->GetResultSet($sql);
      $db->Close();
      while ($row = mysql_fetch_array($rows)) {

          $id = $row['this_id'];

          $biaoti = $row['biaoti'];

          $quyuid = $row['quyu'];


		   $db = Database :: Connect();
          $quyusql = "select * from configuration where this_id =$quyuid";
          $quyuresult = $db->GetSingleRow($quyusql);
		  $quyu = $quyuresult->value;

          $jiage = $row['zujin_goujia'];
          if($row['qiuzu_qiugou']=='1'){
            $danwei = '元';
            $title_head = ' [求租] ';
          }else{
            $danwei = '万';
            $title_head = ' [求购] ';
          }

          $huxing = $row['fangxing'];

          $fabushijian = $row['fabushijian'];


        ?>
    <tr logr="p_0" class="">
      <td class="t"><a href="qiuzu_qiugou.php?id=<?php echo $id?>"
        class="t"><?php echo $title_head.$biaoti?></a><span class="ico area"><?php echo $quyu?></span><span	class="ico biz">（个人）</span></td>
      <td class="tc"><b class="pri"><?php echo $jiage.$danwei; ?></b></td>
      <td class="tc"><?php echo $huxing==""?"未知":$huxing." 室 "?></td>
      <td class="tc"><?php echo time_tran($fabushijian); ?></td>

    </tr>
    <?php }
    $db->Close();
    ?>
  </tbody>
</table>
<div id="bottom_google_ad" style="display: none; margin-top: -1px;"></div>

<?php if(true){
  //page_3
?>
<div class="pager">

  <?php
    if($page!=1){
      echo '<a class="prv" href="'.deleteRepeatVar($current_url,'page').'&page='.($page-1).'"><span>上一页</span></a>';
    }
    if($max_page>10){
      $ind = $page-5;
    }
    if($ind<=0){
      $ind=1;
    }
    $page_show_total = 10;//最多显示10页
    for(;$ind<=$max_page;$ind++){
      if($ind==$page){
        echo '<strong><span>'.$ind.'</span></strong>';
      }else{
        echo '<a href="'.deleteRepeatVar($current_url,'page').'&page='.$ind.'"><span>'.$ind.'</span></a>';
      }
      $page_show_total--;
      if($page_show_total==0){
        break;
      }
    }
    if($page!=$max_page){
      echo '<a class="next" href="'.deleteRepeatVar($current_url,'page').'&page='.($page+1).'"><span>下一页</span></a>';
    }
  ?>

</div>
<?php } ?>

<div id="infocont"><a href="<?php echo $post_url;?>">马上发布一条找房信息»</a></div>
</div>
<div id="rightframe">
<div id="ad19"></div>
</div>
</div>

</div>
